# Location of executable.
BINDIR=bin

#CmdLine driver directory
CmdLinedir=$(PWD)/CmdLine
#fastjet direectory
#FASTJETLOCATION=/home/timlou/research/fastjet
FASTJETLOCATION=/uscms_data/d2/timlou/research/fastjet

# Include CmdLine driver
INCLUDE += -I$(CmdLinedir)
LIBRARIES += -L$(CmdLinedir) -lCmdLine

# root flags
ROOTCXXFLAGS := $(DICTCXXFLAGS) $(shell root-config --cflags)
LDFLAGS1 := $(shell root-config --ldflags --glibs)

# fastjet flags
FASTJETFLAGS := `$(FASTJETLOCATION)/bin/fastjet-config --cxxflags --plugins`
FASTJETLIBS := -L$(FASTJETLOCATION)/lib \
	`$(FASTJETLOCATION)/bin/fastjet-config --libs --plugins`

all: Ntuplizer Ntuplizer_full Ntuplizer_skinnyjet

JetAnalyzer: JetAnalyzer.C
#	rootcint -f EventDict.cc -c
	@mkdir -p $(BINDIR)
	$(CXX) -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C Njettiness.hh \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

FileSkimmer: FileSkimmer.C
	@mkdir -p $(BINDIR)
	$(CXX) -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Ntuplizer: Ntuplizer.C
	@mkdir -p $(BINDIR)
	$(CXX) -O3 -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Ntuplizer_full: Ntuplizer_full.C
	@mkdir -p $(BINDIR)
	$(CXX) -O3 -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Ntuplizer_final: Ntuplizer_final.C
	@mkdir -p $(BINDIR)
	$(CXX) -O3 -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Ntuplizer_display: Ntuplizer_display.C
	@mkdir -p $(BINDIR)
	$(CXX) -O3 -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Ntuplizer_ATLAS: Ntuplizer_ATLAS.C
	@mkdir -p $(BINDIR)
	$(CXX) -O3 -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Ntuplizer_skinnyjet: Ntuplizer_skinnyjet.C
	@mkdir -p $(BINDIR)
	$(CXX) -O3 -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

ATLAS_verification: ATLAS_verification.C
	@mkdir -p $(BINDIR)
	$(CXX) -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Kfactor: Kfactor.C
	@mkdir -p $(BINDIR)
	$(CXX) -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

Plot_maker: Plot_maker.C
	@mkdir -p $(BINDIR)
	$(CXX) -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o


Delphes_Ntuplizer: Delphes_Ntuplizer.C
	@mkdir -p $(BINDIR)
	$(CXX) -w $(ROOTCXXFLAGS) $(INCLUDE)  $@.C \
	$(FASTJETFLAGS) -o $(BINDIR)/$@.exe \
	$(LDFLAGS1) $(FASTJETLIBS) $(LIBRARIES)
	@ln -fs $(BINDIR)/$@.exe $@.exe
	@rm -f $@.o

clean:
	rm -rf $(BINDIR)
	rm -rf *.exe
	rm -f *~; rm -f \#*; rm -f core*
